package com.my.study.commonfallback;

import com.my.study.entity.vo.ResponseVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 微服务调用
 * 公共返回值,能打印报错信息(fallbackFactory = CommonFallback.class)
 */
@Component
@Slf4j
public class CommonFallback implements FallbackFactory<ResponseVO<Object>> {

    @Override
    public ResponseVO<Object> create(Throwable throwable) {
        log.info("接口调用失败,执行熔断逻辑" + throwable.getMessage());
        return ResponseVO.fail("接口执行失败!");
    }
}
